package 接口.接口使用;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 姚东名
 * Date: 2024-06-18
 * Time: 20:22
 */
//笔记本类：使用USB设备
public class Computer implements USB {
    @Override
    public void openDevice() {
        System.out.println("打开笔记本电脑");
    }

    @Override
    public void closeDevice() {
        System.out.println("关闭笔记本电脑");
    }
    //使用电脑：
    public void useDevice(USB usb) {
        usb.openDevice();
        if(usb instanceof Mouse) {
            Mouse mouse = new Mouse();
            mouse.click();
        } else if (usb instanceof KeyBoard) {
            KeyBoard keyBoard = new KeyBoard();
            keyBoard.input();
        }
        usb.closeDevice();
    }
}
